package com.baizhiedu.service;

import com.baizhiedu.dao.UserDAO;
import com.baizhiedu.entity.User;
import org.omg.CORBA.TIMEOUT;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 功能：
 * 作者：HZj
 * 日期：2024/12/29 23:05
 */
//@Transactional(timeout = 2)
//@Transactional(rollbackFor = {java.lang.Exception.class},noRollbackFor = {java.lang.RuntimeException.class})
public class UserServiceImpl implements UserService{
    public UserDAO getUserDAO() {
        return userDAO;
    }

    public void setUserDAO(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    private UserDAO userDAO;

    @Override
    public void register(User user) throws Exception{
//        try {
//            Thread.currentThread().sleep(3000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        userDAO.save(user);
//        throw new RuntimeException("测试");
//        throw new Exception("测试2");
    }

    @Override
//    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public void login(String name, String password) {

    }
}
